Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
WDOG HAL driver

The section describes the programming interface of the WDOG HAL driver. More...

Typedefs

typedef void(* wdog_isr_callback_t )(void)
 Watchdog ISR callback function type.
 

Enumerations

enum  wdog_clock_source_t {
  kWdogDedicatedClock = 0,
  kWdogAlternateClock = 1
}
 Watchdog clock source selection. More...
 
enum  wdog_clock_prescaler_t {
  kWdogClockPrescaler1 = 0,
  kWdogClockPrescaler2 = 1,
  kWdogClockPrescaler3 = 2,
  kWdogClockPrescaler4 = 3,
  kWdogClockPrescaler5 = 4,
  kWdogClockPrescaler6 = 5,
  kWdogClockPrescaler7 = 6,
  kWdogClockPrescaler8 = 7
}
 Define the selection of the clock prescaler. More...
 

Watchdog HAL.

void wdog_hal_enable (void)
 Enable watchdog module. More...
 
void wdog_hal_disable (void)
 Disable watchdog module. More...
 
static bool wdog_hal_is_enabled (void)
 Check whether WDOG is enabled. More...
 
void wdog_hal_configure_interrupt (bool isEnabled)
 Enable and disable watchdog interrupt. More...
 
static bool wdog_hal_is_interrupt_enabled (void)
 Check whether WDOG interrupt is enabled. More...
 
void wdog_hal_set_clock_source (wdog_clock_source_t clockSource)
 set watchdog clock Source. More...
 
static wdog_clock_source_t wdog_hal_get_clock_source (void)
 Get watchdog clock Source. More...
 
void wdog_hal_configure_window_mode (bool isEnabled)
 Enable and disable watchdog window mode. More...
 
static bool wdog_hal_is_window_mode_enabled (void)
 Check whether window mode is enabled. More...
 
void wdog_hal_configure_register_update (bool isEnabled)
 Enable and disable watchdog write-once-only register update. More...
 
static bool wdog_hal_is_register_update_enabled (void)
 Check whether register update is enabled. More...
 
void wdog_hal_configure_enabled_in_cpu_debug_mode (bool isEnabled)
 Set whether watchdog is working while cpu is in debug mode. More...
 
static bool wdog_hal_is_cpu_debug_mode_enabled (void)
 Check whether WDOG works while in CPU debug mode. More...
 
void wdog_hal_configure_enabled_in_cpu_stop_mode (bool isEnabled)
 Set whether watchdog is working while cpu is in stop mode. More...
 
static bool wdog_hal_is_cpu_stop_mode_enabled (void)
 Check whether WDOG works while in CPU stop mode. More...
 
void wdog_hal_configure_enabled_in_cpu_wait_mode (bool isEnabled)
 Set whether watchdog is working while CPU is in wait mode. More...
 
static bool wdog_hal_is_cpu_wait_mode_enabled (void)
 Check whether WDOG works while in CPU wait mode. More...
 
static bool wdog_hal_is_interrupt_asserted (void)
 Get watchdog interrupt status. More...
 
static void wdog_hal_clear_interrupt_flag (void)
 Clear watchdog interrupt flag. More...
 
static void wdog_hal_set_timeout_value (uint32_t timeoutCount)
 set watchdog timeout value. More...
 
static uint32_t wdog_hal_get_timeout_value (void)
 Get watchdog timeout value. More...
 
static uint32_t wdog_hal_get_timer_output (void)
 Get watchdog timer output. More...
 
static void wdog_hal_set_clock_prescaler (wdog_clock_prescaler_t clockPrescaler)
 Set watchdog clock prescaler. More...
 
static wdog_clock_prescaler_t wdog_hal_get_clock_prescaler (void)
 Get watchdog clock prescaler. More...
 
static void wdog_hal_set_window_value (uint32_t windowValue)
 Set watchdog window value. More...
 
static uint32_t wdog_hal_get_window_value (void)
 Get watchdog window value. More...
 
static void wdog_hal_unlock (void)
 Unlock watchdog register written. More...
 
static void wdog_hal_refresh (void)
 Refresh watchdog timer. More...
 
static void wdog_hal_reset_chip (void)
 Reset chip using watchdog. More...
 
static uint32_t wdog_hal_get_reset_count (void)
 Get chip reset count that was reset by watchdog. More...
 
static void wdog_hal_clear_reset_count (void)
 Clear chip reset count that was reset by watchdog. More...
 

Enumeration Type Documentation

Enumerator
kWdogDedicatedClock 

Dedicated clock source (LPO Oscillator),1K HZ.

kWdogAlternateClock 

Alternate clock source, Bus clock.

Enumerator
kWdogClockPrescaler1 

Divide 1, default.

kWdogClockPrescaler2 

Divide 2.

kWdogClockPrescaler3 

Divide 3.

kWdogClockPrescaler4 

Divide 4.

kWdogClockPrescaler5 

Divide 5.

kWdogClockPrescaler6 

Divide 6.

kWdogClockPrescaler7 

Divide 7.

kWdogClockPrescaler8 

Divide 8.

Function Documentation

void wdog_hal_enable ( void  )

This function is used to enable the WDOG and must be called after all necessary configure have been set.

void wdog_hal_disable ( void  )

This function is used to disable the WDOG.

static bool wdog_hal_is_enabled ( void  )
inlinestatic

This function is used check whether WDOG is enabled.

Returns
0 means WDOG is disabled, 1 means WODG is enabled.
void wdog_hal_configure_interrupt ( bool  isEnabled)

This function is used to configure the WDOG interrupt. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
isEnabled0 means disable watchdog interrupt. 1 means enable watchdog interrupt.
static bool wdog_hal_is_interrupt_enabled ( void  )
inlinestatic

This function is used to check whether the WDOG interrupt is enabled.

Returns
0 means interrupt is disabled, 1 means interrupt is enabled.
void wdog_hal_set_clock_source ( wdog_clock_source_t  clockSource)

This function is used to set the WDOG clock source. There are two clock sources that can be used, the LPO clock and the bus clock. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
clockSourcewatchdog clock source, see wdog_clock_source_t.
static wdog_clock_source_t wdog_hal_get_clock_source ( void  )
inlinestatic

This function is used to get the WDOG clock source. There are two clock sources that can be used, the LPO clock and the bus clock.

Returns
watchdog clock source, see wdog_clock_source_t.
void wdog_hal_configure_window_mode ( bool  isEnabled)

This function is used to configure the WDOG window mode. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
isEnabled0 means disable watchdog window mode. 1 means enable watchdog window mode.
static bool wdog_hal_is_window_mode_enabled ( void  )
inlinestatic

This function is used to check whether the WDOG window mode is enabled.

Returns
0 means window mode is disabled, 1 means window mode is enabled.
void wdog_hal_configure_register_update ( bool  isEnabled)

This function is used to configure the WDOG register update feature. If disabled, it means that all WDOG registers will never be written again unless Power On Reset. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
isEnabled0 means disable watchdog write-once-only register update. 1 means enable watchdog write-once-only register update.
static bool wdog_hal_is_register_update_enabled ( void  )
inlinestatic

This function is used to check whether the WDOG register update is enabled.

Returns
0 means register update is disabled, 1 means register update is enabled.
void wdog_hal_configure_enabled_in_cpu_debug_mode ( bool  isEnabled)

This function is used to configure whether the WDOG is enabled in CPU debug mode. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
isEnabled0 means watchdog is disabled in CPU debug mode. 1 means watchdog is enabled in CPU debug mode.
static bool wdog_hal_is_cpu_debug_mode_enabled ( void  )
inlinestatic

This function is used to check whether WDOG works in CPU debug mode.

Returns
0 means not work while in cpu debug mode, 1 means works while in cpu debug mode.
void wdog_hal_configure_enabled_in_cpu_stop_mode ( bool  isEnabled)

This function is used to configure whether the WDOG is enabled in CPU stop mode. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
isEnabled0 means watchdog is disabled in CPU stop mode. 1 means watchdog is enabled in CPU stop mode.
static bool wdog_hal_is_cpu_stop_mode_enabled ( void  )
inlinestatic

This function is used to check whether WDOG works in CPU stop mode.

Returns
0 means not work while in CPU stop mode, 1 means works while in CPU stop mode.
void wdog_hal_configure_enabled_in_cpu_wait_mode ( bool  isEnabled)

This function is used to configure whether the WDOG is enabled in CPU wait mode. The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable function, so this function must be called before wdog_hal_enable is called.

Parameters
isEnabled0 means watchdog is disabled in CPU wait mode. 1 means watchdog is enabled in CPU wait mode.
static bool wdog_hal_is_cpu_wait_mode_enabled ( void  )
inlinestatic

This function is used to check whether WDOG works in CPU wait mode.

Returns
0 means not work while in CPU wait mode, 1 means works while in CPU wait mode.
static bool wdog_hal_is_interrupt_asserted ( void  )
inlinestatic

This function is used to get the WDOG interrupt flag.

Returns
Watchdog interrupt status, 0 means interrupt not asserted, 1 means interrupt asserted.
static void wdog_hal_clear_interrupt_flag ( void  )
inlinestatic

This function is used to clear the WDOG interrupt flag.

static void wdog_hal_set_timeout_value ( uint32_t  timeoutCount)
inlinestatic

This function is used to set the WDOG_TOVAL value.

Parameters
timeoutCountwatchdog timeout value, count of watchdog clock tick.
static uint32_t wdog_hal_get_timeout_value ( void  )
inlinestatic

This function is used to Get the WDOG_TOVAL value.

Returns
value of register WDOG_TOVAL.
static uint32_t wdog_hal_get_timer_output ( void  )
inlinestatic

This function is used to get the WDOG_TMROUT value.

Returns
Current value of watchdog timer counter.
static void wdog_hal_set_clock_prescaler ( wdog_clock_prescaler_t  clockPrescaler)
inlinestatic

This function is used to set the WDOG clock proscaler.

Parameters
clockPrescalerwatchdog clock prescaler, see wdog_clock_prescaler_t.
static wdog_clock_prescaler_t wdog_hal_get_clock_prescaler ( void  )
inlinestatic

This function is used to get the WDOG clock prescaler.

Returns
WDOG clock prescaler.
static void wdog_hal_set_window_value ( uint32_t  windowValue)
inlinestatic

This function is used to set the WDOG_WIN value.

Parameters
windowValuewatchdog window value.
static uint32_t wdog_hal_get_window_value ( void  )
inlinestatic

This function is used to Get the WDOG_WIN value.

Returns
watchdog window value.
static void wdog_hal_unlock ( void  )
inlinestatic

This function is used to unlock the WDOG register written. This function must be called before any configuration is set because watchdog register will be locked automatically after a WCT(256 bus cycles).

static void wdog_hal_refresh ( void  )
inlinestatic

This function is used to feed the WDOG. This function should be called before watchdog timer is in timeout, otherwise a RESET will assert.

static void wdog_hal_reset_chip ( void  )
inlinestatic

This function is used to reset chip using WDOG.

static uint32_t wdog_hal_get_reset_count ( void  )
inlinestatic

This function is used to get the value of WDOG_RSTCNT.

Returns
Chip reset count that was reset by watchdog.
static void wdog_hal_clear_reset_count ( void  )
inlinestatic

This function is used to clear the WDOG_RSTCNT.